package com.lamatek.tags.google;

import java.io.Serializable;

import javax.servlet.jsp.tagext.Tag;
import javax.servlet.jsp.tagext.TagSupport;

/**
 * GoogleMapKeyTag
 * 
 * This tag represents a &lt;googlemaps:key> tag. Developers should not extend or override this class.
 * 
 * @author Tom Cole
 * @version 0.40
 */
public class GoogleMapKeyTag extends TagSupport implements Serializable {
    
    String key = null;
    String domain = null;
    /**
     * Overrides doEndTag() from TagSupport. Developers should not override this method.
     */
    public int doEndTag() {
        Tag tag = this;
        while (tag.getParent() != null) {
            if (tag.getParent() instanceof GoogleMapTag) {
                ((GoogleMapTag) tag.getParent()).addKey(this);
                return EVAL_PAGE;
            }
            tag = tag.getParent();
        }
        return EVAL_PAGE;
    }
    /**
     * Sets the domain name (i.e. www.lamatek.com) that this key was issued for.
     * 
     * @param domain This key's registered domain.
     */
    public void setDomain(String domain) {
        this.domain = domain;
    }
    /**
     * Sets the Google Maps API key that refers to this key's domain.
     * 
     * @param key A valid Google Maps API key for the current domain.
     */
    public void setKey(String key) {
        this.key = key;
    }
}
